//
//  ZQUserAccount.swift
//  ZQWeibo
//
//  Created by summer的Dad on 16/11/15.
//  Copyright © 2016年 summer的Dad. All rights reserved.
//

import UIKit
import YYModel

class ZQUserAccount: NSObject,NSCoding {
    //用户授权
    var access_token:String?
    //
    var uid : String?
    //声明周期
    var expires_in : Double = 0{
        
        didSet{
            
            expires_date = Date(timeIntervalSinceNow: expires_in)
            
        }
    }
    
    override var description: String {
        return yy_modelDescription()
    }
        
        
 
    //增加过期日期属性
    
    var expires_date : Date?
    
    
    //名字头像
    var name: String?
    //头像
    var avatar_large:String?
    
 
  
    
    
    //自定义构造函数
    init(dict: [String : Any]){
        super.init()
        
        setValuesForKeys(dict)
        
   
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    //解档
    required init?(coder aDecoder: NSCoder) {
        
        access_token = aDecoder.decodeObject(forKey: "access_token") as?  String
        uid = aDecoder.decodeObject(forKey: "uid") as?  String
        
        expires_date = aDecoder.decodeObject(forKey: "expires_date") as? Date
        name = aDecoder.decodeObject(forKey: "name") as?  String
        avatar_large = aDecoder.decodeObject(forKey: "avatar_large") as?  String
        //        access_token = aDecoder.decodeObject(forKey: "") as?  String
        
    }
    //归档
    func encode(with aCoder: NSCoder) {
        
        aCoder.encode(access_token, forKey: "access_token")
        aCoder.encode(expires_date, forKey: "expires_date")
        aCoder.encode(uid, forKey: "uid")
        aCoder.encode(name, forKey: "name")
        aCoder.encode(avatar_large, forKey: "avatar_large")
        
    }
    
    
    
    
    
}
